package com.jiangjiang.eshop.wms.convert;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiangjiang.eshop.finance.dto.PurchaseSettlementOrderDTO;
import com.jiangjiang.eshop.finance.dto.PurchaseSettlementOrderItemDTO;
import com.jiangjiang.eshop.purchase.dto.PurchaseOrderDTO;
import com.jiangjiang.eshop.purchase.dto.PurchaseOrderItemDTO;
import com.jiangjiang.eshop.wms.domain.PurchaseInputOrderEntity;
import com.jiangjiang.eshop.wms.dto.PurchaseInputOrderDTO;
import com.jiangjiang.eshop.wms.dto.PurchaseInputOrderItemDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

@Mapper(componentModel = "spring")
public interface PurchaseInputOrderConvert {

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "gmtCreate", ignore = true),
            @Mapping(target = "gmtModified", ignore = true),
            @Mapping(target = "purchaseInputOrderId", source = "purchaseOrderId"),
            @Mapping(target = "goodsSkuId", source = "goodsSkuId"),
            @Mapping(target = "purchasePrice", source = "purchasePrice"),
            @Mapping(target = "purchaseCount", source = "purchaseCount")
    })
    PurchaseInputOrderItemDTO purchaseOrdeItemConvertPurchaseInputOrderItem(PurchaseOrderItemDTO itemDTO);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "gmtCreate", ignore = true),
            @Mapping(target = "gmtModified", ignore = true),
            @Mapping(target = "purchaseOrderId", source = "id"),
            @Mapping(target = "purchaseContractor", source = "contactor"),
            @Mapping(target = "purchaseContractorPhoneNumber", source = "contactorPhoneNumber"),
            @Mapping(target = "purchaseContractorEmail", source = "contactorEmail"),
            @Mapping(target = "purchaseOrderRemark", source = "remark"),
            @Mapping(target = "items",source = "purchaseOrderItemDTOList"),
            @Mapping(target = "status",expression = "java(com.jiangjiang.eshop.wms.constant.PurchaseInputOrderStatus.EDITING)")

    })
    PurchaseInputOrderDTO purchaseOrderConvertPurchaseInputOrder(PurchaseOrderDTO purchaseOrderDTO);

    PurchaseInputOrderEntity convertDTO2Entity(PurchaseInputOrderDTO dto);

    Page<PurchaseInputOrderDTO> converPage2DTO(Page<PurchaseInputOrderEntity> selectPage);

    PurchaseInputOrderDTO convertEntity2DTO(PurchaseInputOrderEntity entity);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "gmtCreate", ignore = true),
            @Mapping(target = "gmtModified", ignore = true),
            @Mapping(target = "status",ignore = true),
            @Mapping(target = "purchaseInputOrderId", source = "purchaseInputOrderDTO.id")


    })
    PurchaseSettlementOrderDTO convert2PurchaseSettlementOrderDTO(PurchaseInputOrderDTO purchaseInputOrderDTO);


    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "gmtCreate", ignore = true),
            @Mapping(target = "gmtModified", ignore = true),
    })
    PurchaseSettlementOrderItemDTO convertInputOrderItem2SettlementOrderItem(PurchaseInputOrderItemDTO itemDTO);
}
